package com.study.bigdata.spark.core.rdd.operator.transform

import org.apache.spark.{SparkConf, SparkContext}

object Scala02_RDD_Operator_Transform_1 {
  def main(args: Array[String]): Unit = {

    val conf = new SparkConf().setMaster("local[*]").setAppName("RDD")
    val sc = new SparkContext(conf)

    // TODO 算子 - 转换 - mapPartitions
    val rdd = sc.makeRDD(List(1,2,3,4),2)
    // 获取每个分区最大值
    // [1,2] [3,4]
    val rdd1 = rdd.mapPartitions(
      list => {
        val max = list.max
        List(max).iterator
      }
    )
    rdd1.collect().foreach(println)
    /*
    2
    4
     */

    sc.stop()



  }

}
